home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / TUT13.ZIP / TUT13.TXT < prev    next >
Text File  |  1994-07-23  |  7KB  |  173 lines

  1.                    ╒═══════════════════════════════╕
  2.                    │         W E L C O M E         │
  3.                    │  To the VGA Trainer Program   │ │
  4.                    │              By               │ │
  5.                    │      DENTHOR of ASPHYXIA      │ │ │
  6.                    ╘═══════════════════════════════╛ │ │
  7.                      ────────────────────────────────┘ │
  8.                        ────────────────────────────────┘
  9.  
  10.                            --==[ PART 13 ]==--
  11.  
  12.  
  13.  
  14. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  15. ■ Introduction
  16.  
  17. Hello again! Here I am, cooped up at home, recovering from my illness
  18. with nothing to do, so of course it is the perfect time to write another
  19. trainer! After the long delay between parts 11 and 12, two trainers in
  20. two days doesn't sound like a bad idea.
  21.  
  22. This trainer is on starfields, which is by request of more then one
  23. person. This is quite an easy effect, and you should have no trouble
  24. grasping the concept behind it. I will be doing a 3d starfield, a
  25. horizontal starfield is very easy with you merely incrementing a x-value
  26. for each star for each frame. I am not even going to bother doing code
  27. for that one (unless requested).
  28.  
  29. So I am off to go grab my antibiotics pills and I will be right back
  30. with the tutorial! ;-)
  31.  
  32.  
  33. If you would like to contact me, or the team, there are many ways you
  34. can do it : 1) Write a message to Grant Smith/Denthor/Asphyxia in private mail
  35.                   on the ASPHYXIA BBS.
  36.             2) Write to Denthor, EzE, Goth, Fubar or Nobody on Connectix.
  37.             3) Write to :  Grant Smith
  38.                            P.O.Box 270 Kloof
  39.                            3640
  40.                            Natal
  41.                            South Africa
  42.             4) Call me (Grant Smith) at (031) 73 2129 (leave a message if you
  43.                   call during varsity). Call +27-31-73-2129 if you call
  44.                   from outside South Africa. (It's YOUR phone bill ;-))
  45.             5) Write to smith9@batis.bis.und.ac.za in E-Mail.
  46.             6) Write to asphyxia@beastie.cs.und.ac.za
  47.  
  48. NB : If you are a representative of a company or BBS, and want ASPHYXIA
  49.        to do you a demo, leave mail to me; we can discuss it.
  50. NNB : If you have done/attempted a demo, SEND IT TO ME! We are feeling
  51.         quite lonely and want to meet/help out/exchange code with other demo
  52.         groups. What do you have to lose? Leave a message here and we can work
  53.         out how to transfer it. We really want to hear from you!
  54.  
  55.  
  56.  
  57. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  58. ■  What is a 3d starfield?
  59.  
  60. I am not even sure if I should do this bit. Go watch any episode of Star
  61. Trek, the movies, Star Wars, or just about any sci-fi movie. Somewhere
  62. there will be a scene where you can see stars whizzing past the
  63. viewscreen, with the ones that are further away moving slower then the
  64. ones that are passed quite close to.
  65.  
  66. This is a 3d starfield. If you look closely, you will see that all the
  67. stars seem to originate from a point, the point you are travelling
  68. towards.  This is an illusion which thankfully happens automatically,
  69. you don't have to code for it ;)
  70.  
  71. Starfields look very nice, and can make a big difference to an otherwise
  72. black background. It also makes a great screen saver ;-)
  73.  
  74.  
  75. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  76. ■  How do they work?
  77.  
  78. This is actually quite simple. Imagine if you will, each star in the
  79. heavens having an x,y and z coordinate, with you being at 0,0,0. Easy?
  80. Right. Now, if you were to say move forward, ie. increase your z value,
  81. to you you will still be at 0,0,0 , but all the stars z values would
  82. have appeared to decrease by the exact same amount.
  83.  
  84. In easier language, we decrease the z value of all the the stars so that
  85. they come closer to you, and eventually whizz past.
  86.  
  87. This solves all our problems. Stars that are close to us on the x and y
  88. scales will pass us by faster then those that are very far from us on
  89. the x and y scales. The only thing we must watch out for is that no star
  90. is at 0,0 , ie. exactly in front of us, otherwise there will be a
  91. collision which will not look good.
  92.  
  93.  
  94. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  95. ■  How do we code this?
  96.  
  97. The first thing to be done is to generate our starfield. This is quite
  98. easy, with us choosing x values between -160 and 160, and y values
  99. between -100 and 100 randomly. Each z is sequentially greater for each
  100. star so that we don't get large areas with no stars. We must remember to
  101. check that there are no stars at 0,0!
  102.  
  103. Okay, now we start the actual viewing section. Here are the steps :
  104.  
  105. 1) Convert our 3-d coords into their 2-d versions. Have a look at tut 8
  106.    to see how this is done, but basically we divide by z.
  107.  
  108. 2) Clear away all old stars that may be on the screen.
  109.  
  110. 3) Draw all our stars according to our 2-d values we have calculated in
  111.    1)
  112.  
  113. 4) Move all the stars either closer to us or further away from us by
  114.    decreasing or increasing their z values respectively.
  115.  
  116. 5) If a star's z value has passed into the negative, place it at the
  117.    very back of our "queue" so that it will come around again
  118.  
  119. 6) Jump back to 1) ad-infinitum.
  120.  
  121. That is, as they say, it. In our sample program the steps have been
  122. neatly placed into individual procedures for easy reading.
  123.  
  124.  
  125. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  126. ■  What next?
  127.  
  128. Okay, so now we have a cool looking starfield. What next? How about
  129. adding left and right motion? A menu or a scrolly in the foreground? How
  130. about figuring out how a star tunnel works? A cool 3d routine going in
  131. front of the stars?
  132.  
  133. A starfield can make just about any routine look just that much more
  134. professional, and can itself be improved to be a great effect all on
  135. it's own.
  136.  
  137.  
  138. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  139. ■  In closing
  140.  
  141. So, this was yet another effect in the series. Do you still want more
  142. effects, or what? Leave me mail with further ideas for trainers. I may
  143. not do it if you don't ask for it!
  144.  
  145. Oh, well, the medicine has been taken, it is time for me to go. Hello to
  146. all those people who have sent me mail, and those great guys on #coders
  147. in IRC (you know who you are). Wow. That is the first greets I have ever
  148. done in a trainer. Hmm. Maybe I'm just ill ;-)
  149.  
  150. Happy coding people!
  151.   - Denthor
  152.       19:28
  153.         24-7-94
  154.  
  155. The following are official ASPHYXIA distribution sites :
  156.  
  157. ╔══════════════════════════╦════════════════╦═════╗
  158. ║BBS Name                  ║Telephone No.   ║Open ║
  159. ╠══════════════════════════╬════════════════╬═════╣
  160. ║ASPHYXIA BBS #1           ║+27-31-765-5312 ║ALL  ║
  161. ║ASPHYXIA BBS #2           ║+27-31-765-6293 ║ALL  ║
  162. ║C-Spam BBS                ║410-531-5886    ║ALL  ║
  163. ║Connectix BBS             ║+27-31-266-9992 ║ALL  ║
  164. ║POP!                      ║+27-12-661-1257 ║ALL  ║
  165. ║Soul Asylum               ║+358-0-5055041  ║ALL  ║
  166. ║Wasted Image              ║407-838-4525    ║ALL  ║
  167. ╚══════════════════════════╩════════════════╩═════╝
  168.  
  169. Leave me mail if you want to become an official Asphyxia BBS
  170. distribution site.
  171.  
  172.  
  173.